#include "Newton.h"
#include<iostream>
#include<fstream>
using namespace std;

double func(double x)
{
	return 1/(1+x * x);
}

int main()
{
	const int n = 2; //n=2,4,6,8
	const int N = 101;
	double x[n+1]={0};
	double x1[N] = { 0 }, y[N] = {0};
	for (int i = 0; i <= n; i++) {
		x[i] = -5.0 + 10.0 * i / n;
	}
	for (int i = 0; i < N; i++) {
		x1[i] = -5 + 0.1 * i;
		y[i] = newton(x, func, n, x1[i]);
	}
	ofstream ocout;
	ocout.open("B1.txt");//当n=2，4，6，8时，输出文件分别为B1.txt，B2.txt，B3.txt，B4.txt
	for (int i = 0; i <N; i++) {
		ocout << x1[i] << " ";
		ocout << y[i] << endl;
	}
	ocout.close();
	return 0;

}
